<?php
class upload_library{
	function __construct()
	{
	  $this->CI = get_instance();
	}     
	function uploadadv($name)
	{
		if(is_uploaded_file($_FILES['filedata']['tmp_name']))
		{
			$filename = stripslashes($_FILES['filedata']['name']);
			$extension = strtolower($this->file_extension($filename));                
			$filename = '../khuyenmai/uploads/quangcao/'.$name.date("dmYHis").'.'.$extension;
			if(move_uploaded_file($_FILES['filedata']['tmp_name'], $filename)){
				return $filename;
			}else{
					return $filename='';  
			}              
		}
		else
		{
			return $filename=''; 
		}
	}
	
	function uploadfile()
	{
		if(is_uploaded_file($_FILES['filedata']['tmp_name']))
		{
			$filename = stripslashes($_FILES['filedata']['name']);
			$size = $_FILES["filedata"]["size"];
             
			$extension = strtolower($this->file_extension($filename)); 
			$name = date("dmYHis").'.'.$extension ;          
			$filename = '../uploads/images/'. $name ;
			$filedata = 'uploads/images/'. $name ;
			if(move_uploaded_file($_FILES['filedata']['tmp_name'], $filename)){
				$size = ($size/1024);
				return $filedata.'*'.$size.'*'.$extension.'*'.$name;
			}else{
				return $filedata='';  
			}              
		}else{
			return $filedata=''; 
		}
	} 
	
	function file_extension($filename)
	{
		$path_info = pathinfo($filename); 
		return $path_info['extension'];
	}
	//---------------------------------------------------------------------------------
	function upload_file()
	{
		if(is_uploaded_file($_FILES['file_data']['tmp_name']))
		{
			
		}
	}
}  
?>
